﻿<UserControl
    x:Class="MySilverlightAlbum.ImageList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignWidth="640"
    d:DesignHeight="480">

    <UserControl.Resources>
    </UserControl.Resources>

    <Grid
        x:Name="layoutRoot"
        Background="Transparent">

        <Popup
            x:Name="imagePopup"
            HorizontalOffset="60">

            <Border
                x:Name="popupBorder"
                Width="500"
                Height="200"
                VerticalAlignment="Stretch"
                HorizontalAlignment="Stretch"
                Background="{StaticResource MenuFill}"
                BorderBrush="{StaticResource ImageBorderBrush}"
                BorderThickness="1"
                CornerRadius="5">

                <Border
                    Margin="4"
                    VerticalAlignment="Stretch"
                    HorizontalAlignment="Stretch"
                    BorderThickness="1"
                    CornerRadius="5"
                    BorderBrush="{StaticResource ImageBorderBrush}">

                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition
                                Height="20" />
                            <RowDefinition
                                Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition
                                Width="295" />
                            <ColumnDefinition
                                Width="*" />
                        </Grid.ColumnDefinitions>

                        <Image
                            Margin="2"
                            Grid.Row="0"
                            Grid.RowSpan="2"
                            Grid.Column="0"
                            Name="magnImage"
                            Source="{Binding ThumbnailImage}"
                            Stretch="Uniform">
                        </Image>

                        <TextBlock
                            Margin="2 2 2 2"
                            Grid.Row="0"
                            Grid.Column="1"
                            VerticalAlignment="Stretch"
                            HorizontalAlignment="Stretch"
                            TextWrapping="NoWrap"
                            FontWeight="Bold"
                            Foreground="{StaticResource ImageTextBrush}"
                            Text="{Binding Title}"></TextBlock>
                        
                        <TextBlock
                            Margin="2 2 2 2"
                            Grid.Row="1"
                            Grid.Column="1"
                            VerticalAlignment="Stretch"
                            HorizontalAlignment="Stretch"
                            TextWrapping="Wrap"
                            Foreground="{StaticResource ImageTextBrush}"
                            Text="{Binding Description}"></TextBlock>

                    </Grid>

                </Border>

            </Border>

        </Popup>

        <ItemsControl
            x:Name="imageList">

            <ItemsControl.Template>
                <ControlTemplate>
                    <ScrollViewer
                        x:Name="scrollviewer"
                        Margin="0"
                        Padding="0"
                        BorderThickness="0"
                        MouseMove="OnScrollMouseWheel"
                        Loaded="OnScrollViewerLoaded"
                        VerticalScrollBarVisibility="Hidden"
                        HorizontalScrollBarVisibility="Hidden">
                        <ItemsPresenter />
                    </ScrollViewer>
                </ControlTemplate>
            </ItemsControl.Template>

            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel
                        x:Name="stackpanel"
                        Loaded="OnStackPanelLoaded"
                        Background="{StaticResource MenuFill}"
                        Orientation="Vertical">

                    </StackPanel>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>

            <ItemsControl.ItemTemplate>
                <DataTemplate>

                    <Image
                        Width="50"
                        Height="50"
                        Margin="2"
                        MouseLeftButtonDown="OnImageSelected"
                        MouseEnter="Image_MouseEnter"
                        MouseLeave="Image_MouseLeave"
                        Stretch="Uniform"
                        Source="{Binding ThumbnailImage}" />

                </DataTemplate>
            </ItemsControl.ItemTemplate>

        </ItemsControl>

    </Grid>
</UserControl>
